package stream;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

//定义集合添加12345678910，过滤奇数留下偶数并保存
public class Test1 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Integer> list = new ArrayList<>();
        //添加
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        //
        List<Integer> newList = list.stream()   //放入流水线
                .filter(n -> n % 2 == 0)    //进行过滤
                .collect(Collectors.toList());  //进行收集，Collectors.toList()进行创建新的list，然后存入
        System.out.println(newList);
    }
}
